import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:ytbusiness/config/style.dart';
import 'package:ytbusiness/config/yt_theme.dart';
import 'package:ytbusiness/utils/helper.dart';
import 'package:ytbusiness/utils/screen_adaptation.dart';
import 'package:ytbusiness/widgets/widgets.dart';

//发票管理
class InvoiceManagement extends StatefulWidget {
  @override
  _InvoiceManagementState createState() => _InvoiceManagementState();
}

class _InvoiceManagementState extends State<InvoiceManagement> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: YTStyle.bgColor,
      appBar: AppBar(
        elevation: 0.5,
        centerTitle: true,
        backgroundColor: Colors.white,
        title: Text(
          "发票管理",
          style: TextStyle(
              color: Color(0xff323232),
              fontSize: setSp(18),
              fontWeight: FontWeight.w600),
        ),
        leading: GestureDetector(
          behavior: HitTestBehavior.opaque,
          onTap: () {
            Navigator.pop(context);
          },
          child: Row(
            children: [
              Container(
                  margin: EdgeInsets.only(left: setWidth(15)),
                  width: setWidth(10),
                  height: setWidth(17),
                  child: Image.asset(
                    "assets/images/return.png",
                    fit: BoxFit.cover,
                  )),
            ],
          ),
        ),
        actions: [
          GestureDetector(
            behavior: HitTestBehavior.opaque,
            onTap: () {
              urlPush(context, "yuntu://add_invoice");
            },
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Container(
                  margin: EdgeInsets.only(right: setWidth(15)),
                  child: Text(
                    "新增",
                    style: TextStyle(color: YTTheme.theme, fontSize: setSp(15)),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
      body: Container(
        color: Colors.white,
        margin: EdgeInsets.only(top: setWidth(15)),
        child: ListView(
          shrinkWrap: true,
          children: [
            _item("四纪星辉传媒有限公司四纪星辉传媒有限公司四纪星辉传媒有限公司四纪星辉传媒有限公司", voidBack: () {
              urlPush(context, "yuntu://edit_invoice");
            }),
            _item("四纪星辉传媒有限公司", voidBack: () {}),
            _item("四纪星辉传媒有限公司", voidBack: () {}),
          ],
        ),
      ),
    );
  }

  Widget _item(String title, {VoidCallback voidBack}) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: () => voidBack(),
      child: Column(
        children: [
          Container(
            padding: EdgeInsets.only(left: setWidth(15), right: setWidth(15)),
            height: setWidth(60),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Expanded(
                  child: Container(
                    child: Text(
                      title,
                      style: TextStyle(
                          color: Color(0xff323232), fontSize: setSp(15)),
                      maxLines: 1,
                      overflow: TextOverflow.ellipsis,
                    ),
                  ),
                ),
                SizedBox(
                  width: setWidth(10),
                ),
                Container(
                  child: Text(
                    "编辑",
                    style: TextStyle(
                        color: Color(0xff989898), fontSize: setSp(15)),
                  ),
                )
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(left: setWidth(15), right: setWidth(15)),
            height: setWidth(0.5),
            color: Color(0xffF0F0F0),
          )
        ],
      ),
    );
  }
}
